package com.eco.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface ChartMapper {

    @Select("SELECT \n" +
            "    p.project_name,\n" +
            "    SUM(l.amount) AS total_liability\n" +
            "FROM \n" +
            "    projects p\n" +
            "LEFT JOIN \n" +
            "    liabilities l ON p.project_id = l.project_id\n" +
            "GROUP BY \n" +
            "    p.project_id, p.project_name;")
    List<HashMap> chartA();

    @Select("SELECT " +
            "    p.project_name, " +
            "    IFNULL(SUM(i.amount), 0) AS total_income, " +
            "    IFNULL(SUM(e.amount), 0) AS total_expense " +
            "FROM projects p " +
            "LEFT JOIN incomes i ON p.project_id = i.project_id " +
            "LEFT JOIN expenses e ON p.project_id = e.project_id " +
            "GROUP BY p.project_id, p.project_name")
    List<HashMap> chartB();



}




























